<? 
include "jumaro-main.inc.php";

include "jumaro-dal.php";

include "clases/_message.class.php";

include "_resources/_resourcesNegocios.php";
include "_resources/_resourcesCategorias.php";

	require_once "securimage/securimage.php";	
	
	

	
	function checkControlFormulario($datos){
		
		$securimage = new Securimage();			
		
		$message = "";
		$break = "<br />";
		
		if($datos['NombreCompleto'] == ""){
			$message .= "Campo Nombre es Incorrecto" . $break ;
		}
		
		if($datos['Email'] == ""){
			$message .= "Campo Email es Incorrecto" . $break ;
		}
		
		if($datos['categoria'] == 0){
			$message .= "Campo categoria es Incorrecto" . $break ;
		}
		
		if($datos['Consulta'] == ''){
			$message .= "Campo Descripcion es Incorrecto" . $break ;
		}
		
		if ($securimage->check($_POST['captcha_code']) == false) {
			$message .= "Campo Codigo es incorrecto" . $break ;
		}
				
		
		return $message;

	}

	$message_text = "";
	$NombreCompleto = "";
	$Email = "";
	$Descripcion = "";
	$IdCategoria = 0; 
	
	
	if(isset($_POST['btnConsulta']))
	{
		$message = new _message();
		
		$message->set_width('98%');
		
		$check_error = checkControlFormulario($_POST);

		$NombreCompleto = $_POST['NombreCompleto'];
		$Email = $_POST['Email'];
		$IdCategoria = $_POST['categoria'];
		$Descripcion = $_POST['Consulta'];

		if($check_error == ""){
			
			_altaQuieroComprar($NombreCompleto,$Email,$IdCategoria,$Descripcion);
			
			$message->set_message('se registro su quiero comprar.-','exitos');
			
			$NombreCompleto = "";
			$Email = "";
			$Descripcion = "";
			$IdCategoria = 0; 			
			
		}else{
			$message->set_message($check_error,'errores');
		}
		
		$message_text = $message->get_message();
	}


//cabeceraHtml_beta("JUMARO Contactos", "salta,precio,descuentos", "", "");
htmlHEADER("JUMARO - Tu vidriera al alcance de un click", "salta,precio,descuentos", "");
?>


<div class="bg_body">
<div class="bg2_body">
<div class="wrapper-padd">
<div id="bodyWrapper" class="container_16 ofh">

<?
inicioEncabezado();
		mostrarLogo();		
		menuSuperior(3);
finEncebezado();

//A partir de aqui muestro el contenido de la pagina
inicioContenido();
	tituloContenido('Quiero Comprar: ALTA');
?>



	<div class="contentContainer log">
	  <div class="contentPadd loginPage">

			<div style=" border-left: 0px solid #e5e5e5;">
				
				<div style="" class="contentInfoText marg-top">

					<?

						if($message_text != ""){ echo $message_text; }

					?>

					<form method="post" action="" name="form_quiero_compras" id="form_quiero_compras">
						<input type="hidden" value="f5f16b4697ad2f87acab16bf47d55c6c" name="formid">
						<table width="100%" cellspacing="0" cellpadding="2" border="0">
						  <tbody>
						  	<tr>
						        <td class="fieldKey">Nombre Completo: <span style='font-weight:bold;color:#F16503;'>*</span></td>
						        <td class="fieldValue"><input type="text" name="NombreCompleto" id="NombreCompleto" style="width:515px;" value="<?=$NombreCompleto?>"></td>
						      </tr>
						      <tr>
						        <td class="fieldKey">&nbsp;</td>
						        <td class="fieldValue">&nbsp;</td>
						      </tr>						      
						      <tr>
						        <td class="fieldKey">Email: <span style='font-weight:bold;color:#F16503;'>*</span></td>
						        <td class="fieldValue"><input type="text" maxlength="40" name="Email" id="Email" style="width:515px;" value="<?=$Email?>"></td>
						      </tr>
						      <tr>
						        <td class="fieldKey">&nbsp;</td>
						        <td class="fieldValue">&nbsp;</td>
						      </tr>						      
						      <tr>
						        <td class="fieldKey">Categoria: <span style='font-weight:bold;color:#F16503;'>*</span></td>
						        <td class="fieldValue">
					        		<select class="input" name="categoria" id="categoria">
										<option selected="selected" value="0">Elija una opcion</option>
										<?php 
										$rows=GetCategorias();
										
										while ($row = mysql_fetch_assoc($rows)) {
											$id=$row["id"];
											$nombre_categoria=$row["nombre"];
											if($IdCategoria == $id){
												?>
												<option value="<?=$id?>" selected><? echo htmlentities($nombre_categoria); ?></option>
												<? 							
											}else{
												?>
												<option value="<?=$id?>"><? echo htmlentities($nombre_categoria); ?></option>
												<? 							
											}
					
										}
										?>
									</select>						        
						        </td>
						      </tr>
						      <tr>
						        <td class="fieldKey">&nbsp;</td>
						        <td class="fieldValue">&nbsp;</td>
						      </tr>
						      <tr>
						        <td class="fieldKey" valign="top">Descripcion: <span style='font-weight:bold;color:#F16503;'>*</span></td>
						        <td class="fieldValue">
						        	<textarea name="Consulta" id="Consulta" style="width:515px;height:245px;"><?=$Descripcion?></textarea>
						        </td>
						      </tr>
						      <tr>
						        <td class="fieldKey">&nbsp;</td>
						        <td class="fieldValue">&nbsp;</td>
						      </tr>
						      <tr>
						        <td class="fieldKey" valign="top">Codigo: <span style='font-weight:bold;color:#F16503;'>*</span></td>
						        <td class="fieldValue">
						        	<img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" align="absmiddle" />
						        	&nbsp;
									<input type="text" name="captcha_code" id="captcha_code" size="10" maxlength="6" style="border:1px solid #CCC;padding:5px;" />
									<a href="#" onclick="document.getElementById('captcha').src = 'securimage/securimage_show.php?' + Math.random(); return false">
									 <img id="captcha" src="images/refresh.png" alt="CAPTCHA Image" />
									</a>						        	
						        </td>
						      </tr>							      
						      <tr>
						        <td class="fieldKey" valign="top"></td>
						        <td class="fieldValue">
	        	
						        </td>
						      </tr>
						      <tr>
						        <td class="fieldKey"></td>
						        <td class="fieldValue"></td>
						      </tr>
						      <tr>
						      <td colspan="2" align="right">
						      	<input type="submit" name="btnConsulta" id="btnConsulta" value="enviar" class="classButton">
						      </td>
						      </tr>
							</tbody>
						</table>
						
						<!--<div class="buttonSet btn_position">
							<span class="buttonAction">
								<div onmouseover="this.className='bg_button22-act';" onmouseout="this.className='bg_button22';" class="bg_button22">
									<input type="submit" name="btnConsulta" id="btnConsulta" value="enviar consulta">
								</div>
							</span>
						</div>-->
					
					 	<br />
					
					</form>
	
			</div>
				<div>
				    <span style="color:#F16503" class="inputRequirement">* Informacion necesaria</span>
				</div>			
		</div>
	</div>
	
</div>


<?php 
finContenido();
menuIzquierdo();
?>

</div>
</div>
</div>
</div>
<?php 
pie();
?>	
</body>
<!--[if IE]>
  <link href="css/ie_style.css" rel="stylesheet" type="text/css" />
<![endif]-->
</html>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7078796-2");
pageTracker._trackPageview();
} catch(err) {}</script>